package src.driver;

import src.controller.*;
import src.event.events.ConsoleUpdateEvent;
import src.event.events.CursorChangeEvent;
import src.event.events.SelectionUpdateEvent;
import src.view.ViewHandler;
import src.view.ViewHandler.DisplayType;
import src.view.ViewEventHandler;
import src.view.Splash;
import src.model.gameWorld.GameWorld;
import src.model.gameWorld.MapTileConfiguration;
import src.model.gameWorld.Position;

public abstract class Driver{

	private static ViewHandler vh;

	public static void startGame(PlayerObjectData [] pods, MapTileConfiguration tileConfig){
		vh.setDisplayType(tileConfig);
		GameController gc = new GameController(pods);

		Position.setXBoundary(5);
		Position.setYBoundary(5);

		MainViewKeyListener mvkl = new MainViewKeyListener(gc);
		UnitOverviewKeyListener uokl = new UnitOverviewKeyListener(gc);
		StructureOverviewKeyListener sokl = new StructureOverviewKeyListener(gc);

		MapMouseListener mml = new MapMouseListener(gc);
		AbilityMouseListener aml = new AbilityMouseListener(gc);
		UnitOverviewMouseListener uoml = new UnitOverviewMouseListener(gc);
		StructureOverviewMouseListener soml = new StructureOverviewMouseListener(gc);
		TechnologyOverviewMouseListener toml = new TechnologyOverviewMouseListener(gc);

		vh.registerMainViewKeyListener(mvkl);
		vh.registerUnitOverviewKeyListener(uokl);
		vh.registerStructureOverviewKeyListener(sokl);
		vh.registerMapMouseListener(mml);
		vh.registerAbilityMouseListener(aml);
		vh.registerUnitOverviewMouseListener(uoml);
		vh.registerStructureOverviewMouseListener(soml);
		vh.registerTechnologyOverviewMouseListener(toml);

		vh.setDisplay(DisplayType.MAIN);

		new GameWorld(pods, tileConfig);
		ViewEventHandler.fireEvent(new CursorChangeEvent(0, 0));

		/*This class has to do the following things:

		1. Init MainScreen
		2. Display the opening screen.
		3. Create a special controller object to handle the number of players, player names, player colors, and player keymap.
		4. After all that information has been done, create PlayerObjectData for each player.
		5. Create the GameController passing it the PODs.
		6. Create the MouseListener and KeyListener.
		7. Add both of these to the MainScreen.
		8. Create the GameWorld.
		9. Begin the first turn.

		*/
	}

	public static void initGame()
	{
//		Splash.show(3500);

		vh = new ViewHandler(MapTileConfiguration.Octagonal);

		vh.setDisplay(DisplayType.STARTUP);
	}


	public static void main(String[] args){
		Driver.initGame();
	}
}
